perf(workflow): optimize YAML parsing with custom UnmarshalYAML#86
Open
watany-dev wants to merge 1 commit intomainfrom
Open
perf(workflow): optimize YAML parsing with custom UnmarshalYAML#86watany-dev wants to merge 1 commit intomainfrom
watany-dev wants to merge 1 commit intomainfrom
Conversation
Implement custom UnmarshalYAML methods for WorkflowFile, Job, and Step structs to avoid reflection overhead and eliminate redundant node traversal. Key optimizations: - Single-pass extraction of struct fields and JobOrder in WorkflowFile - Direct field assignment instead of reflection-based Decode calls - Pre-allocated slices and maps with exact capacity - Simplified LoadWorkflowFile by removing parseWorkflowFromNode and extractJobOrderFromNode helper functions Benchmark results (10 jobs × 5 steps each): - Speed: 774,299 ns/op → 693,108 ns/op (10.5% faster) - Memory: 206,857 B/op → 194,120 B/op (6.2% reduction) - Allocations: 3,837 → 3,109 (19.0% reduction) Code simplification: load.go reduced from 84 to 28 lines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement custom UnmarshalYAML methods for WorkflowFile, Job, and Step
structs to avoid reflection overhead and eliminate redundant node traversal.
Key optimizations:
extractJobOrderFromNode helper functions
Benchmark results (10 jobs × 5 steps each):
Code simplification: load.go reduced from 84 to 28 lines.